package config;

public enum ConfigValueType
{
	E_INT_CVT("int"),
	E_INT_16_CVT("hex int"),
	E_STRING_CVT("string"),
	E_LONG_CVT("hex int"),
	E_BOOL_CVT("bool"),
	;
	
	private String m_text;
	
	private ConfigValueType(String text)
	{
		m_text = text;
	}
	
	public String getText()
	{
		return m_text;
	}
	
	public Object checkType(String value)
	{
		switch(this) 
		{
		case E_BOOL_CVT:
			return checkBool(value);
		case E_INT_16_CVT:
			return checkInt16(value);
		case E_INT_CVT:
			return checkInt(value);
		case E_LONG_CVT:
			return checkLong(value);
		case E_STRING_CVT:
			return value;
		default:
			return null;
		}
	}
	
	private Integer checkInt(String value)
	{
		Integer i = null;
		try 
		{
			i = Integer.parseInt(value);
		} 
		catch(Exception e)
		{
		}
		return i;
	}
	
	private Integer checkInt16(String value)
	{
		Integer i = null;
		try 
		{
			i = Integer.parseInt(value, 16);
		} 
		catch(Exception e)
		{
		}
		return i;
	}
	
	private Long checkLong(String value)
	{
		Long i = null;
		try 
		{
			i = Long.parseLong(value, 16);
		} 
		catch(Exception e)
		{
		}
		return i;
	}
	
	private Boolean checkBool(String value)
	{
		Boolean b = null;
		if(value.compareTo("true") == 0)
		{
			b = true;
		}
		else if(value.compareTo("false") == 0)
		{
			b = false;
		}
		return b;
	}
}
